<?php

// Wenn man nicht die benötigten Rechte besitzt, dann darf die Seite nicht aufgerufen werden
if (!hasPermission('section=game')) {
	return new Ret(PERMISSION_DENIED. ': Missing right(s) for section=game');
}

// Das action array für game.php
$action = array();
$action['catalogue']	= 'game/catalogue.php';
$action['view']			= 'game/view.php';
$action['create']		= 'game/create.php';

// Den Rückgabewert von game.php vorbereiten
$game_ret = new Ret();

// Schauen, welche action geladen werden soll
if (isset($_GET['action'])) {
	
	if (!isset($action[$_GET['action']])) {
		
		$game_ret = new Ret(ERR_ACTION_DOES_NOT_EXIST. ': '. $_GET['action']);
		
		// warn
		$logger->logFile('The action '. $_GET['action'] .' does not exsist.', LEVEL_WARN);
		
	} else if (file_exists('includes/'. $action[$_GET['action']])) {
		
		// Die gewünschte action laden
		$game_ret = include 'includes/'. $action[$_GET['action']];
		
	} else {
		
		$game_ret = new Ret(INCLUDE_NOT_FOUND_EXCEPTION . ': includes/'.$action[$_GET['action']]);

		// error
		$logger->logFile("The include file '". 'includes/'.$action[$_GET['action']] ."' was not found.", LEVEL_ERROR);
	
	}
}

if (!$game_ret->get_template()) {
	
	if (file_exists('includes/'. $action['catalogue'])) {
		
		$game_ret = include 'includes/'. $action['catalogue'];
		
	} else {
		
		$game_ret = new Ret(INCLUDE_NOT_FOUND_EXCEPTION . ': includes/'.$action['catalogue']);
		// error
		$logger->logFile("The include file '". 'includes/'.$action['catalogue'] ."' was not found.", LEVEL_ERROR);
	
	}
}

return $game_ret;

?>